import java.io.*;
import javax.swing.JFileChooser;

/**
 * This is an implementation and comparison of open addressing with linear probing,
 * quadratic probing, and double hashing
 * 
 * @author Fredy F. Murillo
 * @version 1.0
 */
public class p1_muri {	
	
    //Choose a file from a directory
	public static void main(String[] args) 
    {
        String[] lines = new String[0];  
        String filename = File.separator+"tmp";
        
        JFileChooser chooser = new JFileChooser(new File(filename));
        chooser.showOpenDialog(null);
        
        File file = chooser.getSelectedFile();

        //String path = "data.txt";
        BufferedReader br = null;
        try {
            //File file = new File(path);
            br = new BufferedReader(
                 new InputStreamReader(
                 new FileInputStream(file)));
            String line;
            while( (line = br.readLine()) != null ) {
                lines = add(line, lines);   //here is the array
            }
            br.close();
        } catch(IOException e) {
            System.out.println("read error: " + e.getMessage());
        }
        System.out.println("Array " + lines[0]);
        print(lines);
        System.out.println("Array " + lines[0]);
    }
	
    //add method
    private static String[] add(String s, String[] array) 
    {
        int len = array.length;
        String[] temp = new String[len+1];
        System.arraycopy(array, 0, temp, 0, len);
        temp[len] = s;
        return temp;
    }
   //Print the array
    private static void print(String[] data) 
    {
        for(int i = 0; i < data.length; i++)
            System.out.println(data[i]);
    }
}